#pragma once

#include <AVUIProjectionCamera.h>

namespace AVUI {
    
class PerspectiveCamera : public ProjectionCamera
{
public:
    PerspectiveCamera() { };

    DECLARE_ELEMENT(PerspectiveCamera, ProjectionCamera);

    DECLARE_DEPENDENCY_PROPERTY(FieldOfView);
    float get_FieldOfView() { return AVUI::UnboxValue<float>(GetValue(get_FieldOfViewProperty())); }
    void set_FieldOfView(float value) { SetValue(get_FieldOfViewProperty(), AVUI::BoxValue(value)); } 

    virtual Matrix3D GetProjectionMatrix(float aspectRatio);
    virtual TRefCountedPtr<RayHitTestParameters> RayFromViewportPoint(const Point& point, const Size& viewSize, const Rect3D& boundingRect, float* pDistanceAdjustment) AVUI_OVERRIDE;

protected:
    virtual TRefCountedPtr<Freezable> CreateInstanceCore() AVUI_OVERRIDE { return object_allocate<PerspectiveCamera>().get_Ptr(); }

private:
    static void StaticConstructor();

    Matrix3D GetProjectionMatrix(float aspectRatio, float zn, float zf);

};


}; // namespace AVUI

